<template>
    <base-breadcrumb>
        <searchData :search-data="searchArr" @search="search" />
        <a-card :bordered="false">
            <!-- <title-name title="固定资产验收" /> -->
            <list-table ref="table"  :columns="columns" :request="loadData">
                <template slot="prefix">
                    <a-button type="primary" icon="plus" @click="$nav('add')"> 新增 </a-button>
                </template>
                <span slot="index" slot-scope="text, record, index">{{ index + 1 }}</span>
                <template slot="createTime" slot-scope="text, record">
                    {{ record.createTime | dateFormat('D') }}
                </template>
                <template slot="entryTime" slot-scope="text, record">
                    {{ record.entryTime | dateFormat('D') }}
                </template>
                <template slot="auditStatusStr" slot-scope="text, record">
                    <list-status :status="record.auditStatus" :text="text" />
                </template>
                <template slot="operation" slot-scope="text, record">
                    <div class="pub-table-list-action">
                        <span @click="$nav('add', { id: record.id, detail: 1 })">查看</span>
                        <span v-if="record.statusStr !== '已提交'" @click="$nav('add', { id: record.id })">编辑</span>

                        <span v-btnPermission="'oa_035_del_03'" @click="handleDel(record.id)">删除</span>
                    </div>
                </template>
            </list-table>
        </a-card>
    </base-breadcrumb>
</template>

<script>
import assetApi from '@/api/office/asset'
import SelectCompanyAndProject from '@/components/Select/SelectCompanyAndProject'
import SelectPerson from '@/components/Select/SelectPerson'
import SelectOrgDepartment from '@/components/Select/SelectOrgDepartment'
import BSelect from '@/components/BComponents/BSelect'
import OrgTreeSelect from '@/components/OrgTreeSelect'

export default {
    name: 'AssetManagementIndex',
    data() {
        return {
            rowId: '',
            pathName: this.$route.path,
            columns: [
                {
                    title: '序号',
                    dataIndex: 'index',
                    scopedSlots: { customRender: 'index' }
                },
                {
                    title: '资产编号',
                    dataIndex: 'assetCode',
                },
                {
                    title: '资产名称',
                    dataIndex: 'assetName',
                },
                {
                    title: '资产类别',
                    dataIndex: 'assetSpeciesStr',
                },
                {
                    title: '单位',
                    dataIndex: 'unit',
                },
                {
                    title: '数量',
                    dataIndex: 'number',
                },
                {
                    title: '申请购置单位',
                    dataIndex: 'unitName',
                },
                {
                    title: '申请购置部门',
                    dataIndex: 'depName',
                },
                {
                    title: '验收日期',
                    dataIndex: 'acceptanceTime',
                },
                {
                    title: '状态',
                    dataIndex: 'statusStr',
                    scopedSlots: { customRender: 'recycleStatus' },
                },
                {
                    title: '操作',
                    fixed: 'right',
                    scopedSlots: { customRender: 'operation' }
                }
            ],
            searchArr: [
                // 搜索框
                {
                    name: '申请购置单位',
                    valueKey: 'searchQuery',
                    type: OrgTreeSelect,
                    attrs: {
                        isAutoSelectFirst: true,
                        isNeedOrgId: true
                    }
                },
                // {
                //     name: '申请购置单位',
                //     type: SelectCompanyAndProject,
                //     valueKey: 'unitId',
                //     isAuth: false,
                //     isAutoSelectMe: true
                // },
                {
                    name: '申请购置部门',
                    valueKey: 'depId',
                    keyValue: 'searchQuery._checked',
                    type: SelectOrgDepartment,
                    isAutoSelectMe: true,
                    isOrgIdNotNull: true,
                    isSearch: true
                },
                {
                    name: '资产名称',
                    value: 'assetName',
                    type: 'input'
                },
                {
                    name: '资产类别',
                    valueKey: 'assetSpecies',
                    type: BSelect,
                    data: [],
                    request: () => assetApi.typesLabel({ type: 18 })
                },
                {
                    name: '资产编号',
                    value: 'assetCode',
                    type: 'input'
                }
            ],
            loadData: (params) => {
                return assetApi.getPage(Object.assign(params, { query: this.queryParam }))
            },
            queryParam: {
                // unitId: this.$currentPost().id,
                // depId: this.$currentPost().deptId
            }
        }
    },
    created() { },
    methods: {
        search(val) {
            this.queryParam = val || {}
            this.$refs.table.getData(null, true)
        },
        handleDel(id) {
            this.$delList3(
                assetApi.delete,
                () => {
                    this.search()
                },
                { id }
            )
        }
    }
}
</script>
